package com.dexing.od2;

import java.util.Scanner;

/**
 *  题目描述 输入单行英文句子，里面包含英文字母，空格以及.? 三种标点符号，
 *  请将句子内每个单词进行倒序，并输出倒序后的语句
 *  输入描述: 输入字符串S，S的长度1≤N≤100
 *  输出描述: 输出逆序后的字符串 补充说明: 标点符号左右的空格>=0，单词间空格 >0 
 *  示例1
 *  输入: yM eman si boB.
 *  输出: My name is Bob.
 *  示例2
 *  输入: woh era uoy ? I ma enif.
 *  输出: how are you ? I am fine.
 */
public class D0101ReaverStr {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        char[] chars = s.toCharArray();
        String res = "";
        String tem = "";
        for (int i = 0; i < chars.length; i++) {
            char c = chars[i];
            if (Character.isLetter(c)){
                tem+= c;
            } else if (c == ' ') {
                res += reverse(tem) + " ";
                tem = "";
            } else {
                if (!tem.equals("")) {
                    res+= reverse(tem);
                    tem = "";
                }
                res += c;
            }
            if (i == chars.length -1 && tem != "") {
                res += reverse(tem);
            }
        }
        System.out.println(res);
    }

    private static String reverse(String s) {
        StringBuffer bf = new StringBuffer();
        for (int i = s.length()-1; i >= 0; i--) {
            Character c = s.charAt(i);
            bf.append(c);
        }
        return bf.toString();
    }

}
